<?php

namespace XWAM\Addon\POrgSystem\Controller;

/**
 * Description of VarConfigController
 *
 * @since 1.0 <2015-10-20> SoChishun <14507247@qq.com> Added.
 */
class VarConfigController extends AddonbaseController {
    function var_config_search_data(){
        $search=$_GET;
        if($search['search_key']){
            $where['_string']=  sprintf("name like '%s' or title like '%s'",$search['search_key'],$search['search_key']);
        }
        return array('where'=>$where,'search'=>$search);
    }
    function var_config(){
        $asearch_info=$this->var_config_search_data();
        $list = AddonD('Config')->get_paging_list($asearch_info['where'], $show, array('ORDER'=>'sort, id desc','PAGEPARAMS' => $asearch_info['search']));
        $this->assign('list',$list);
        $this->assign('page', $show);
        $this->assign('search', $asearch_info['search']);
        $this->display_cpp();
    }
    function var_edit($id=''){
        $this->assign('data',AddonD('Config')->find($id));
        $this->display();
    }
    function var_edit_save(){
        $result=AddonD('Config')->save_var();
        $this->dialogJump($result['status'],$result['info']);
    }
    function var_delete($id=''){
        $result=AddonD('Config')->remove_var($id);
        $this->ajaxReturn($result);
    }
    
    function change_status($id, $status){
        $this->ajaxReturn(AddonD('Config')->change_status($id,$status));
    }
}
